<!doctype html>


<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>portchannel.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>





<div class="colmask rightmenu">
<div class="colleft">
    <div class="col1">
      <!-- Column 1 start -->

<div id="title">
       <span class="fn">portchannel.js</span>
</div>

<div class="g-section g-tpl-75-25">
  <div class="g-unit g-first" id="description">
    <span class='nodesc'>No description.</span>
  </div>
  

        <div class="g-unit" id="useful-links">
          <div class="title">Useful links</div>
          <ol>
            <li><a href="local_closure_goog_messaging_portchannel.js.source.html"><span class='source-code-link'>Source Code</span></a></li>
            <li><a href="http://code.google.com/p/closure-library/source/browse/local/closure/goog/messaging/portchannel.js">Git</a></li>
          </ol>
        </div>
</div>

<h2 class="g-first">File Location</h2>
  <div class="g-section g-tpl-20-80">
    <div class="g-unit g-first">
      <div class="g-c-cell code-label">/goog/messaging/portchannel.js</div>
    </div>
  </div>
<hr/>


  <h2>Classes</h2>
 <div class="fn-constructor">
        <a href="class_goog_messaging_PortChannel.html">
          goog.messaging.PortChannel</a><br/>
        <div class="class-details">A wrapper for several types of HTML5 message-passing entities
(<code> MessagePort</code>s and <code> WebWorker</code>s). This class implements the
<code> goog.messaging.MessageChannel</code> interface.

This class can be used in conjunction with other communication on the port.
It sets <code> goog.messaging.PortChannel.FLAG</code> to true on all messages it
sends.

</div>
 </div>
      
<br/>

  <div class="legend">
        <span class="key publickey"></span><span>Public</span>
        <span class="key protectedkey"></span><span>Protected</span>
        <span class="key privatekey"></span><span>Private</span>
  </div>









<div class="section">
  <table class="horiz-rule">


  </table>
</div>




  <h2>Global Functions</h2>





<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.messaging.PortChannel.forEmbeddedWindow&disposeTimer"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.messaging.PortChannel.</span><span class="entryName">forEmbeddedWindow&disposeTimer<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_portchannel.js.source.html#line110">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.messaging.PortChannel.forEmbeddedWindow"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.messaging.PortChannel.</span><span class="entryName">forEmbeddedWindow<span class="args">(<span class="arg">window</span>,&nbsp;<span class="arg">peerOrigin</span>,&nbsp;<span class="arg">opt_timer</span>)</span>
        </span>
        &#8658; <span>!</span><span class="type"><a href="class_goog_messaging_DeferredChannel.html">goog.messaging.DeferredChannel</a></span>
      </div>


     <div class="entryOverview">
       Create a PortChannel that communicates with a window embedded in the current
page (e.g. an iframe contentWindow). The code within the window should call
<code> forGlobalWindow</code> to establish the connection.

It's possible to use this channel in conjunction with other messages to the
embedded window. However, only one PortChannel should be used for a given
window at a time.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">window</span>
        : <span>!</span><span class="type"><a href="https://developer.mozilla.org/en/DOM/window">Window</a></span>
        <div class="entryOverview">The window object to communicate with.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">peerOrigin</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The expected origin of the window. See
    <a href="http://dev.w3.org/html5/postmsg/#dom-window-postmessage">http://dev.w3.org/html5/postmsg/#dom-window-postmessage</a>.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_timer</span>
        : <span class="type">goog.Timer=</span>
        <div class="entryOverview">The timer that regulates how often the initial
    connection message is attempted. This will be automatically disposed once
    the connection is established, or when the connection is cancelled.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>!</span><span class="type"><a href="class_goog_messaging_DeferredChannel.html">goog.messaging.DeferredChannel</a></span>&nbsp;
            The PortChannel. Although this is
    not actually an instance of the PortChannel class, it will behave like
    one in that MessagePorts may be sent across it. The DeferredChannel may
    be cancelled before a connection is established in order to abort the
    attempt to make a connection.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_portchannel.js.source.html#line106">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.messaging.PortChannel.forGlobalWindow"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.messaging.PortChannel.</span><span class="entryName">forGlobalWindow<span class="args">(<span class="arg">peerOrigin</span>)</span>
        </span>
        &#8658; <span>!</span><span class="type"><a href="interface_goog_messaging_MessageChannel.html">goog.messaging.MessageChannel</a></span>
      </div>


     <div class="entryOverview">
       Create a PortChannel that communicates with the document in which this window
is embedded (e.g. within an iframe). The enclosing document should call
<code> forEmbeddedWindow</code> to establish the connection.

It's possible to use this channel in conjunction with other messages posted
to the global window. However, only one PortChannel should be used for the
global window at a time.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">peerOrigin</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The expected origin of the enclosing document. See
    <a href="http://dev.w3.org/html5/postmsg/#dom-window-postmessage">http://dev.w3.org/html5/postmsg/#dom-window-postmessage</a>.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>!</span><span class="type"><a href="interface_goog_messaging_MessageChannel.html">goog.messaging.MessageChannel</a></span>&nbsp;
            The PortChannel. Although this may
    not actually be an instance of the PortChannel class, it will behave like
    one in that MessagePorts may be sent across it.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_portchannel.js.source.html#line165">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.messaging.PortChannel.forEmbeddedWindow&function%0&gotMessage"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.messaging.PortChannel.</span><span class="entryName">forEmbeddedWindow&function%0&gotMessage<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_messaging_portchannel.js.source.html#line125">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>






      <!-- Column 1 end -->
    </div>

        <div class="col2">
          <!-- Column 2 start -->
          <div class="col2-c">
            <h2 id="ref-head">Directory messaging</h2>
            <div id="localView"></div>
          </div>

          <div class="col2-c">
            <h2 id="ref-head">File Reference</h2>
            <div id="sideFileIndex" rootPath="" current="/goog/messaging/portchannel.js"></div>
          </div>
          <!-- Column 2 end -->
        </div>
</div>
</div>

</body>
</html>
